import api from '../../api';
import { message } from 'antd';
export default {
  namespace: 'bondLendingM',

  state: {},

  effects: {
    //价格试算
    *basicInfo({ payload, callback }, { call, put }) {
      const response = yield call(api.basicInfo, payload);
      if (response) {
        if (response.success == true) {
          callback(response.data);
        } else {
          message.error('获取债券基础信息失败');
        }
      } else {
        message.error('获取债券基础信息失败');
      }
    },

    //根据组合id获取在途回购信息
    *getBuyBack({ payload, callback }, { call, put, select }) {
      const res = yield call(api.bondLending.getBuyBack, payload);
      if (res && res.code == 0) {
        callback(res.data);
      } else {
        message.error(res.msg || '查询在途回购信息失败!');
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
